﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
namespace SmartDesktop
{
    public partial class ViewOrderInfo : Form
    {
        public ViewOrderInfo()
        {
            InitializeComponent();
        }

        private void ViewOrderInfo_Load(object sender, EventArgs e)
        {
            
        }

        private void PrintPanel(Panel pnl)
        {
            PrintDialog myPrintDialog = new PrintDialog();
            System.Drawing.Bitmap memoryImage = new System.Drawing.Bitmap(pnl.Width, pnl.Height);
            pnl.DrawToBitmap(memoryImage, pnl.ClientRectangle);
            if (myPrintDialog.ShowDialog() == DialogResult.OK)
            {
                System.Drawing.Printing.PrinterSettings values;
                values = myPrintDialog.PrinterSettings;
                myPrintDialog.Document = printDocument1;
                printDocument1.PrintController = new StandardPrintController();
                printDocument1.Print();
            }
            printDocument1.Dispose();
        }

        private void btnPrint_Click(object sender, EventArgs e)
        {            
          //  printForm1.Print();
            PrintPanel(pnlInfo);        
        }

        private void Doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            float x = e.MarginBounds.Left;
            float y = e.MarginBounds.Top;
            Bitmap bmp = new Bitmap(this.pnlInfo.Width, this.pnlInfo.Height);
            this.pnlInfo.DrawToBitmap(bmp, new Rectangle(0, 0, this.pnlInfo.Width, this.pnlInfo.Height));
            e.Graphics.DrawImage((Image)bmp, x, y);
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
           
        }

        private void btnEdit_Click(object sender, EventArgs e)
        {

        }
        
       
    }
}
